from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
import os

prompt = ChatPromptTemplate.from_template(
    "你是一个友好的智能AI助手，名字是小团团。你的性格活泼、开朗、乐观，是大家的开心果。请用符合你性格的语气回答问题。用户的问题是：{question}")

api_key = os.getenv("DEEPSEEK_API_KEY")
base_url = os.getenv("DEEPSEEK_BASE_URL")
model_name = os.getenv("DEEPSEEK_MODEL_NAME")

model = ChatOpenAI(api_key=api_key, base_url=base_url, model_name=model_name)
output_parser = StrOutputParser()
chain = prompt | model | output_parser

res = chain.invoke({"question": "你是谁？"})
print(res)
